# Maintainer: Alexey Pavlov <Alexpux@gmail.com>
# Contributor: Paul Moore <p.f.moore@gmail.com>

_realname=wget
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.16.3
pkgrel=1
pkgdesc='Wget retrieves files using HTTP, HTTPS and FTP (mingw-w64)'
arch=('any')
url='https://www.gnu.org/software/wget/'

license=('GPL3')

depends=("${MINGW_PACKAGE_PREFIX}-pcre"
         "${MINGW_PACKAGE_PREFIX}-libidn"
         "${MINGW_PACKAGE_PREFIX}-openssl"
        )

source=("https://ftp.gnu.org/gnu/${_realname}/${_realname}-${pkgver}.tar.xz")
sha256sums=('67f7b7b0f5c14db633e3b18f53172786c001e153d545cfc85d82759c5c2ffb37')
options=('strip' '!libtool' 'staticlibs')

prepare() {
  cd $srcdir/${_realname}-${pkgver}
}

build() {
  cd $srcdir/${_realname}-${pkgver}
  ./configure --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --with-ssl=openssl

  make
}

package() {
  cd ${srcdir}/${_realname}-${pkgver}
  make install DESTDIR="${pkgdir}"

  # Licenses
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/README" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/README"
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
